package com.jcfk.eam.controller.mould;

import com.jcfk.common.business.log.annotation.RequestLogHeader;
import com.jcfk.common.web.domain.RetResult;
import com.jcfk.eam.domain.dto.mould.SizeDetailTrendService;
import com.jcfk.eam.domain.query.main.EamPointCheckOrderQuery;
import com.jcfk.eam.enums.AssetKind;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * 入库尺寸明细趋势
 *
 * @author yrl
 * @email
 * @date 2024-11-06
 */
@Api(tags = {"入库尺寸明细趋势"})
@RestController
@RequestMapping("teSizeDetailTrend")
public class SizeDetailTrendController {


    @Resource
    private SizeDetailTrendService sizeDetailTrendService;
    /**
     *  入库尺寸明细趋势
     */
    @ApiOperation("入库尺寸明细趋势")
    @PostMapping("/query")
    @RequestLogHeader(modular = "资产点检工单管理")
    public RetResult<?> sizeDetailTrend(@RequestBody EamPointCheckOrderQuery requestParam) {
        requestParam.setAssetKind(AssetKind.MOULD.getValue());
        // todo sop_type_code 待定 模具入库点检(尺寸)

        return RetResult.ok(sizeDetailTrendService.sizeDetailTrend(requestParam));
    }

    public static void main(String[] args) {
        try {
            URL url = new URL("https://api.bridgevision-dev-cn.com:460/api/WorkAuth/getauthinfo?tenantId=10");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuffer response = new StringBuffer();

            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());

            connection.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
